import time

from selenium.webdriver.common.by import By
from selenium import webdriver
from Base.Base import Base

class Page2(Base):

    #点击请登录
    login_loc=(By.XPATH,'/html/body/div[2]/div/div[1]/div/a[1]')
    def login(self):
        self.sbclick(self.login_loc)
    #输入账号
    user_loc=(By.ID,'userName')
    def username(self):
        self.send_keys(self.user_loc,'133811484')
    #输入密码
    pass_loc=(By.ID,'password')
    def password(self):
        self.send_keys(self.pass_loc,'grq200566++')
    #点击登录
    loginan_loc=(By.XPATH,'/html/body/div/form/div/div/div/div/div[1]/div[2]/div[4]/input')
    def loginan(self):
        self.click(self.loginan_loc)
    # 点击确认
    qr_loc = (By.ID, 'bindSub')
    def qr(self):
        self.click(self.qr_loc)
    #搜索框输入
    souso_loc=(By.ID,'wd')
    def souso(self):
        self.send_keys(self.souso_loc,'五粮液')
    def luoji_jiuxian_sousuo(self):
        try:
            self.open_url('https://login.jiuxian.com/')
            self.login()
            time.sleep(4)
            self.username()
            self.password()
            time.sleep(15)
            self.loginan()
            self.qr()
            time.sleep(5)
            self.jianpan(self.souso_loc)
        except Exception as e:
            t = time.strftime('%Y%m%d%H%M%S', time.localtime())
            self.driver.save_screenshot(f'{t}error.png')
            print(e)